package cn.it.shop.service.impl.flow;

import java.util.List;

import org.springframework.stereotype.Service;

import cn.it.shop.model.flow.FlowItem;
import cn.it.shop.service.flow.FlowItemService;
import cn.it.shop.service.impl.BaseServiceImpl;

/***
 * 流程后续推送service实现
 * @author fangyangsheng
 *
 */
@Service("flowItemService")
public class FlowItemServiceImpl extends BaseServiceImpl<FlowItem> implements FlowItemService{

	
	/**
	 * 根据流程主体id查找是否有对应的后续推送流程
	 * @param flowReplyId
	 * @return 流程后续推送集合
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<FlowItem> queryByFlowReplyId(long flowReplyId) {
		String hql = "From FlowItem WHERE flowReply = "+flowReplyId;
		return getSession().createQuery(hql).list();
	}
	
	/**
	 * //根据"步骤值"和"流程主体id"确定 要执行的后续流程
	 * @param sortnum 步骤值
	 * @param flowReplyId 流程主体id
	 * @return 流程后续推送
	 */
	@Override
	public FlowItem getBySortnumAndfFlowReplyId(int sortnum, long flowReplyId) {
		String hql = "From FlowItem WHERE flowReply =:flowReply and sortnum =:sortnum";
		return (FlowItem) getSession().createQuery(hql)
				.setLong("flowReply", flowReplyId)
				.setInteger("sortnum", sortnum)
				.uniqueResult();
		
	}

}
